package v3.chapter6.singleton_1; 

public class Run {

	public static void main(String[] args) {
		MyThread t1 = new MyThread(); 
		t1.start(); 
	}
}

class MyThread extends Thread {
	@Override
	public void run() {
		System.out.println(MyObject.getInstance().hashCode());
	}
}

class MyObject {
	// 延迟加载
	private static MyObject myObject;

	private MyObject() {
	}

	public static MyObject getInstance() {
		if (myObject != null) {

		} else {
			myObject = new MyObject();
		}

		return myObject;
	}
}